#include <cstddef>
#include <iostream>
#define lld long long
using std::cin;
using std::cout;

int main() {
  lld n, x;
  cin >> n;
  for (size_t i = 1; i <= n; ++i)
    cin >> x;
  cout << n * (n - 1) / 2;

  return 0;
}